<template>
  <div class="newscontentpage">
    <h3>{{newscontents.title}}</h3>
    <p class="titlespan">
        <span>发表时间:{{newscontents.add_time | timeFilter}}</span>
        <span>点击次数:{{newscontents.click}}</span>
    </p>
    <hr>
    <!-- 新闻详情内容 -->
    <div class="newscontent" v-html="newscontents.content"></div>
    <!-- 评论子组件 -->
    <!-- 需要向子组件传递参数 -->
    <commentz :id="id"></commentz>
  </div>
</template>
<script>
import { Toast } from 'mint-ui';

import commentz from './../subcomment/CommentZ.vue'
export default {
  data() {
    return {
    // 接收路由传递的参数
     id: this.$route.params.id,
    // 获取数据存储到数组里
      newscontents: []
    };
  },
  components:{
      commentz
  },
  created() {
    this.getNewscontent();
  },
  methods: {
    getNewscontent() {
      this.$http.get("api/getnew/"+ this.id).then((res) => {
        // console.log(res.body)
        if (res.body.status === 0) {
          this.newscontents = res.body.message[0];
        }else{
            Toast('加载新闻详情失败');
        }
      });
    }
  }
};
</script>
<style lang="less" >
.newscontentpage {
    padding: 2px 5px;
    h3{
        font-size: 20px;
        text-align: center;
    }
  .titlespan{
    display: flex;
    justify-content: space-between;
    color: #26a2ff;
    font-size: 13px;
  }
  .newscontent{
    img {
      width:100%;
    }
  }
}
</style>